Source Code Viewer - Example 3 - CountryCodeAlreadyExistsRuleException

package name.matthewgreet.example3.exception;

/**
 * Exception indicating failure to add a country as it would duplicate country code.  
 */
public class CountryCodeAlreadyExistsRuleException extends Exception {
	private static final long serialVersionUID = -1731964459047244851L;
	
	private int existingId;
	private String code;
	
	public CountryCodeAlreadyExistsRuleException(int existingId, String code) {
		super("Country code " + code + " already exists for country id " + existingId);
		this.existingId = existingId;
		this.code = code;
	}

	@Override
	public String toString() {
		return "CountryCodeAlreadyExistsRuleException [existingId=" + existingId + ", code=" + code + ", getMessage()="
				+ getMessage() + "]";
	}

	public int getExistingId() {
		return existingId;
	}

	public String getCode() {
		return code;
	}
	
}